package conson.tech.manage.facade.config;

import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.PropertyAccessor;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;

import java.io.IOException;

/**
 * InterfaceName: MyRedissonConfg
 * Description: Redisson配置类
 * Author: XYF
 * Date: 2020/7/25 13:37
 * Version: 1.0
 */
@Configuration
public class MyRedissonConfg {


    /**
     * 所有对Redisson的操作都是使用RedissonClient对象
     *
     * @return org.redisson.api.RedissonClient
     */
    @Bean(destroyMethod = "shutdown")
    public RedissonClient redisson() throws IOException {

//        创建配置
        Config config = new Config();
        config.useSingleServer().setAddress("redis://121.42.15.96:8888");
//        根据配置创建出RedissonClient实例
        return Redisson.create(config);
    }
}
